PIC32 USB Starter Kit III: Running the Port_IO demo
------------------------------------------------------
 
Required Development Resources:
-----------------------------------
a. PIC32 Starter Kit (DM320003-3)
b. MPLAB-X IDE.
c. XC32 C Compiler, ver 1.21 or later.


Compiling and Running the Demo:
-------------------------------
1. Load the demo project into MPLAB-X: File->Open Project-> (browse into the project location) select "port_io_-_PIC32_Starter_Kit.X"->click "Open Project".
2. Connect the mini-B debugger port on-board the Starter board to an USB port on the development computer using the USB cable provided in the kit.
3. Choose the PIC32 PKOB debugger tool in MPLAB-X IDE by right-clicking the project name in the Projects window (left side)->Properties->in the Hardware Tool window, find "Starter Kits (PKOB)" and just below, select the device serial number as is appears.
4. Build the project by selecting Run->Build Main Project.
5. Run the demo code in debug mode by selecting Debug>Debug Main Project.  Use the debug icons as they appear for run, pause, step, stop debugging, etc.
6. To Download code into the microcontroller without debugging, select "Make and Program Device" icon (down arrow).


This example code uses the PIC32 Peripheral Library macros to configure PORTD IO port pins as digital outputs and digital inputs as well as configure IO pin Change Notice, weak pin pullups and Change Notice Interrupts.

The program demonstrates two different methods to monitor SW1 (PORTD.RD6) and SW2 (PORTD.RD7) on the PIC32 USB Starter Kit III.

Method #1 polls SW1 in software.

When SW1 is pressed, LED1 (PORTD.RD0) is turned on.

When SW1 is released, LED1 is turned off.

Method #2 uses IO pin Change Notice for SW2 to generate an interrupt.

Pressing or releasing SW2 causes a Change Notice interrupt to be generated and the Change Notice ISR reads the PORT to determine the state of SW2.

When SW2 is pressed, LED2 (PORTD.RD1) is turned on.

When SW1 is released, another interrupt is generated, SW1 is read again, then LED2 is turned off.


